package org.agile2soft.nexoma.core.dao.hibernate;

import java.util.List;

import org.agile2soft.nexoma.core.dao.ServiceOptionDAO;
import org.agile2soft.nexoma.core.entities.Service;
import org.agile2soft.nexoma.core.entities.ServiceOption;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import br.com.arsmachina.dao.hibernate.GenericDAOImpl;

public class ServiceOptionDAOImpl extends GenericDAOImpl <ServiceOption,Integer> implements ServiceOptionDAO {

    public ServiceOptionDAOImpl(SessionFactory sessionFactory) {
        super(sessionFactory);
    }

    public List<ServiceOption> findByService(Integer id) {
        Criteria c = createCriteria();
        c.add(Restrictions.eq("service.id",id));
        c.addOrder(Order.asc("name"));
        return c.list();
    }

    public List<ServiceOption> findByService(Service service) {
        Criteria c = createCriteria();
        c.add(Restrictions.eq("service",service));
        c.addOrder(Order.asc("name"));
        return c.list();
    }

}
